package com.jiazhong.project.service;


import com.jiazhong.project.mapper.UserMapper;
import com.jiazhong.project.utils.SqlSessionFactoryUtils;
import com.jiazhong.project.pojo.User;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;

import java.util.List;


public class UserService {
    SqlSessionFactory sqlSessionFactory = SqlSessionFactoryUtils.getSqlSessionFactory();

    public User login(User user) {
        final SqlSession session = sqlSessionFactory.openSession();
        final UserMapper userMapper = session.getMapper(UserMapper.class);
        User users = userMapper.login(user);
        return users;
    }
    public void register(User user) {
        final SqlSession session = sqlSessionFactory.openSession();
        final UserMapper userMapper = session.getMapper(UserMapper.class);
        userMapper.register(user);
        session.commit();
    }
}
